define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {


        index: function () {
            //
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'feedback/index/index',
                    add_url: 'feedback/index//add',
                    table: '',
                }
            });

            var table = $("#table1");

            // 初始化表格
            table.bootstrapTable({
                url: 'feedback/index/indexajax',
                pk: 'id',
                sortName: 'id',
                search: false,
                showSearch: false,
                method:'post',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID', operate: false},
                        {field: 'nickname', title: __('用户'), operate: false},
                        {field: 'name', title: __('客户信息'), operate: false},
                        {field: 'msg', title: __('提交信息'), operate: false},
                        {field: 'time', title: __('访问时间'), operate: false, formatter: Table.api.formatter.datetime},
                        {
                            field: 'buttons',
                            width: "160px",
                            title: __('按钮组'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'ajax',
                                    classname: 'btn btn-xs btn-success btn-magic btn-ajax',
                                    icon: 'fa  fa-check',
                                    url: 'feedback/index/setsuccess',
                                    confirm: '确认通过！',
                                    success: function (data, ret) {

                                        location.reload();
                                    }
                                },
                                {
                                    name: 'ajax',
                                    classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
                                    icon: 'fa fa-trash',
                                    url: 'feedback/index/delete',
                                    confirm: '确认删除？',
                                    success: function (data, ret) {
                                        location.reload();
                                    }
                                },

                            ],
                            formatter: Table.api.formatter.buttons
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
            Controller.api.bindevent();
        },


        index1: function () {
            //
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'feedback/index/index',
                    add_url: 'feedback/index//add',
                    table: '',
                }
            });

            var table = $("#table1");

            // 初始化表格
            table.bootstrapTable({
                url: 'feedback/index/index1ajax',
                pk: 'id',
                sortName: 'id',
                search: false,
                showSearch: false,
                method:'post',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID', operate: false},
                        {field: 'nickname', title: __('用户'), operate: false},
                        {field: 'name', title: __('客户信息'), operate: false},
                        {field: 'msg', title: __('提交信息'), operate: false},
                        {field: 'time', title: __('访问时间'), operate: false, formatter: Table.api.formatter.datetime},
                        {
                            field: 'buttons',
                            width: "160px",
                            title: __('按钮组'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'ajax',
                                    classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
                                    icon: 'fa fa-trash',
                                    url: 'feedback/index/delete',
                                    confirm: '确认删除？',
                                    success: function (data, ret) {
                                        location.reload();
                                    }
                                },

                            ],
                            formatter: Table.api.formatter.buttons
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
            Controller.api.bindevent();
        },


        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
